require.config({
    baseUrl:"../modules",
    paste:{
        jq:"../libs/jquery"
    },
})

require(["jq",],function(_,){
    const url = "http://localhost:3000/data.login.json/api"

    $(".loginBut-s").click(function(){
        $.ajax({
            url:url,
            data:{
                name:$(".register-boxx-bottom-d-s2-ipt1").val(),
                password:$(".register-boxx-bottom-d-s2-ipt2").val(),
                type:"login",
            },
            success:res=>{
                console.log(res)
                let ttt =JSON.parse(res)
                if(ttt.code == 1){
                    localStorage.setItem("token","ok")
                    localStorage.setItem("uname",ttt.data.name)
                    if(confirm("登录成功！是否前往首页。。")){
                        location.href="../index.html"
                    }
                }else if(ttt.code == 0){
                    alert("帐号或密码输入错误。。。")
                    $(".register-boxx-bottom-d-s2-ipt1").val("")
                    $(".register-boxx-bottom-d-s2-ipt2").val("")
                    $(".register-boxx-bottom-d-s2-ipt1")[0].focus();
                    localStorage.setItem("token","no")
                }

            },
        })
    })



})